//41查询列表   53点击查询键   63跳转到会签界面
<template>
  <div>
    <el-card class="box-card">
      <h2>会签合同</h2>
      <el-form :model="queryForm" label-width="120px">
        <el-form-item label="合同名称：">
          <el-input v-model="queryForm.name"></el-input>
        </el-form-item>
        <el-form-item class="centered-button">
          <el-button type="primary" @click="queryContracts">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table :data="contracts" style="width: 100%">
        <el-table-column prop="name" label="合同名称"></el-table-column>
        <el-table-column prop="draftTime" label="开始时间"></el-table-column>
        <el-table-column label="操作">
          <template #default="scope">
            <el-button type="primary" size="mini" @click="countersignContract(scope.row)">会签</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      queryForm: {
        name: ''
      },
      contracts: []
    };
  },
  created() {
    this.fetchPendingContracts();
  },
  methods: {
    fetchPendingContracts() {
      this.axios.get('/api/contract/listCounterSignContract')
        .then(response => {
         console.log('API Response:', response.data); // 打印返回的数据
          this.contracts = response.data.data;
        })
        .catch(error => {
          console.error('Error fetching pending contracts:', error);
        });
    },
    queryContracts() {
      const params = {
        name: this.queryForm.name
      };
      this.axios.get('/api/counterSigneContracts/query', { params })
        .then(response => {
          this.contracts = response.data.data;
        })
        .catch(error => {
          console.error('Error querying contracts:', error);
        });
    },
    countersignContract(contract) {
      this.$router.push({ path: `/countersign_contract2/${contract.name}` });
    }
  }
};
</script>

<style scoped>
.box-card {
  margin: auto;
  width: 800px;
}
.el-form-item {
  margin-bottom: 20px;
}
.centered-button {
  display: flex;
  justify-content: center;
}
</style>
t